<template>
  <f-badge :color="viewModel.color" v-if="viewModel&&viewModel.text">{{viewModel.text}}</f-badge>
</template>
<script>
  export default {
    data () {
      return {
        viewModel: {
          text: null,
          color: ''
        }
      }
    },
    props: {
      type: {
        default: null
      },
      value: {
        type: Number,
        default: 0
      }
    },
    mounted () {
      this.init()
    },
    methods: {
      init () {
        var find = this.$api.enumValue(this.type, this.value)
        if (find) {
          this.viewModel.text = find.value
          this.viewModel.color = find.cssType
        }
      }
    },
    watch: {
      value: {
        deep: true,
        handler: 'init'
      }
    }
  }
</script>
